package com.example.Service.impl;

import com.example.Mapper.UsersMapper;
import com.example.Service.UserService;
import com.example.entity.Users;
import com.example.entity.vo.UsersVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserImpl implements UserService {
    @Autowired
    UsersMapper usersDao;
    @Override
    public PageInfo<UsersVo>  selectAll(UsersVo uservo) {
        List<UsersVo> usersVoList= usersDao.selectAll(uservo);
        if(uservo.getPageNum() !=null && uservo.getPageSize()!=null){
            PageHelper.startPage(uservo.getPageNum(),uservo.getPageSize());
        }
        return new PageInfo<>(usersVoList);
    }

    @Override
    public List<UsersVo> selectAllT(UsersVo usersVo) {
        return usersDao.selectAll(usersVo);
    }

    @Override
    public int deletById(Integer userId) {
        return usersDao.deletById(userId);
    }

    @Override
    public int insert(Users user) {
        return usersDao.insertUser(user);
    }

    @Override
    public int update(Users user) {
        return usersDao.updateUser(user);
    }
}
